package pl.s7n.paint.utils;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JButton;

/**
 * Customized JButton with possibility to change its fore- & background on setColor(..) call.
 * 
 * @author 7
 */
public class JButtonAsColor extends JButton {
  private static final long serialVersionUID = -8001215284604042410L;

  public JButtonAsColor() {
    setPreferredSize(new Dimension(100, 25));
    setMaximumSize(new Dimension(100, 25));
    setMinimumSize(new Dimension(50, 25));
    setText("Color");
    setIcon(null);

    setColor(Color.BLACK);
  }

  public void setColor(Color color) {
    setBackground(color);
    setForeground(new Color(~color.getRGB())); // inverse color
  }
}
